home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / optivc16 / matrix.txt < prev    next >
Encoding:
Text File  |  1999-03-06  |  55.4 KB  |  1,079 lines

  1.        OOOOOO                            VV        VV
  2.       OO    OO   PPPPPPP   TTTTTTTT  II   VV      VV  EEEEEE   CCCCCC
  3.       OO    OO   PP    PP     TT     II    VV    VV   EE       CC
  4.       OO    OO   PPPPPPP      TT     II     VV   VV   EEEEEE   CC
  5.       OO    OO   PP           TT     II       VVV     EE       CC
  6.        OOOOOO    PP           TT     II        V      EEEEEE   CCCCCC
  7.  
  8.  
  9.                        OptiVec  Version 1.5
  10.  
  11.               Part Three: Description of MatrixLib
  12.  
  13.                      Dr. Martin Sander Software Development
  14.                      Sertürnerstr. 11
  15.                      D-37085 Göttingen
  16.                      Germany
  17.                      e-mail: MartinSander@Bigfoot.com
  18.                      http://www.optivec.com
  19.  
  20. ****************************************************************************
  21.  
  22. !!     This is an ASCII text file!  It is best viewed with a simple        !!
  23. !!     DOS editor.                                                         !!
  24. !!     If you load this file into a word processor under Windows, you      !!
  25. !!     must use the filter "DOS text".                                     !!
  26. !!     Alternatively, you may use FCONVERT (shipped with Borland C++) to   !!
  27. !!     convert from ASCII (OEM) into the ANSI character set.               !!
  28. !!     Preferrably use the lettertype CourierNew 10 pt.                    !!
  29.  
  30. A general description of OptiVec is given in the  F i r s t  P a r t
  31. of this documentation, in the file HANDBOOK.TXT.
  32. Chapter 1.2 of that file contains the licence terms.
  33. See FUNCREF.TXT for the description of VectorLib functions,
  34. and CMATH.TXT for CMATH functions.
  35.  
  36. Copyright for the Software and its documentation (C) 1996-1999 Martin Sander
  37.  
  38.  
  39. ****************************************************************************
  40. *                                                                          *
  41. *******                           Contents                           *******
  42. *                                                                          *
  43. ****************************************************************************
  44.  
  45.  1. Introduction
  46.  2. Management of Dynamically Generated Matrices
  47.  3. Initialization of Matrices
  48.  4. Data-Type Conversions
  49.  5. Transposing and Extracting Parts from a Matrix
  50.  6. Arithmetic Operations Performed on a Single Row, Column, or the Diagonal
  51.  7. Operations Performed Along All Rows or All Columns Simultaneously
  52.  8. Operations Involving Two Rows or Two Colums
  53.  9. Matrix Multiplication
  54. 10. Linear Algebra 
  55. 11. Eigenvalues and Eigenvectors
  56. 12. Two-Dimensional Fourier-Transform Methods
  57. 13. Data Fitting
  58. 14. Matrix Input and Output
  59. 15. Graphical Representation of Matrices
  60. 16. Alphabetical Syntax Reference
  61.  
  62.  
  63. 1. Introduction
  64. -------------------------
  65.  
  66. Before reading this documentation about MatrixLib, you should have read the
  67. introductory chapters of the VectorLib handbook. MatrixLib builds upon the
  68. principles established in VectorLib. As VectorLib defines vector data types,
  69. here are the matrix data types, defined in MatrixLib:
  70.  
  71.   fMatrix   matrix of floats
  72.   dMatrix   matrix of doubles
  73.   eMatrix   matrix of extended (= long double)
  74.   cfMatrix  matrix of fComplex (= complex<float>)
  75.   cdMatrix  matrix of dComplex (= complex<double>)
  76.   ceMatrix  matrix of eComplex (= complex<extended>)
  77.  
  78. The ordering of elements is the same as in the two-dimensional arrays
  79. provided by the respective target compilers. This means that the matrices
  80. are stored row-wise in MatrixLib versions for C and C++ compilers, but
  81. column-wise in versions for Pascal and Fortran.
  82. At present, integer matrices are defined, but no functions are available
  83. for them.
  84.  
  85. While we recommend to exclusively use these dynamically allocated matrix
  86. types, static matrices defined, e.g., as
  87.     float  MX[4][6];
  88. can be used in all MatrixLib functions with the exception of the multiLinfit
  89. and multiNonlinfit routines.
  90.  
  91. Each MatrixLib function has a prefix defining the data type on which it acts:
  92.  
  93. MF_  for arguments of the types fMatrix, float and fVector
  94. MD_  for arguments of the types dMatrix, double and dVector
  95. ME_  for arguments of the types eMatrix, extended (long double) and eVector
  96. MCF_ for arguments of the types cfMatrix, fComplex and cfVector
  97. MCD_ for arguments of the types cdMatrix, dComplex and cdVector
  98. MCE_ for arguments of the types ceMatrix, eComplex and ceVector
  99.  
  100. In the C/C++ version (but not in the Pascal/Delphi version!), all functions
  101. taking matrix arguments exist in a second form. In this form, all matrix
  102. arguments are replaced by pointers to the first elements of the respective
  103. matrices. You can explicitly use the second form by leaving away the underbar
  104. of the function-name prefix.  Calling
  105.      MF_mulM( MC, MA, MB, htA, lenA, lenB );
  106. is equivalent to calling
  107.      MFmulM(&(MC[0][0]),&(MA[0][0]),&(MB[0][0]),htA,lenA,lenB);
  108. or   MFmulM( MC[0], MA[0], MB[0], htA, lenA, lenB );
  109.  
  110. Actually, the run-time routines are in the second form, and the macros
  111. defined in <MFstd.h> etc. convert calls to the first form into calls to the
  112. second form.
  113. In the following chapters, a brief summary of all MatrixLib function is given,
  114. ordered into groups according to their functionality. At the end of this
  115. file, chapter 16 gives a syntax reference in alphabetical order.
  116.  
  117.  
  118. 2. Management of Dynamically Generated Matrices
  119. -----------------------------------------------
  120.  
  121. MF_matrix      allocate memory for a matrix
  122. MF_matrix0     allocate memory and set all elements 0
  123. M_free         free one matrix (data-type independent)
  124. M_nfree        free n matrices (data-type independent)
  125. V_freeAll      free all existing vectors and matrices
  126.  
  127. OptiVec's dynamically allocated matrices can be addressed just like two-
  128. dimensional static arrays of C/C++. If you have, e.g., an fMatrix MX and
  129. a variable float a, you can write a line like
  130.      a = MX[3][5];
  131.  
  132. Additionally, there are two functions addressing single elements
  133. (which are necessary for Pascal and for getting around the
  134. pointer arithmetics bug in some versions of Borland C++):
  135.  
  136. MF_Pelement    Pointer to a specific matrix element
  137. MF_element     value of a specific matrix element
  138.  
  139.  
  140. 3. Initialization of Matrices
  141. -----------------------------
  142.  
  143. In order to initialize all matrices with the same value, or to perform
  144. the same arithmetic operation on all matrix elements simultaneously,
  145. please use the respective VectorLib function. You can do so, because
  146. all matrices are in fact stored as vectors, occupying a contiguous space
  147. in memory. All you have to do is to pass the first row of the matrix
  148. (rather than the matrix itself) to the vector function.
  149. Fore example, you can initialize all matrix elements with a constant C
  150. by calling
  151.     VF_equC( MA[0], ht*len, C );
  152. As you will see, some of the most common operations of this kind
  153. are also explicitly defined in MatrixLib, like initialization with zero,
  154. MF_equ0, or multiplication by a constant, available as MF_mulC
  155. (see chapter 9).
  156.  
  157. Here are the typical matrix initialization functions:
  158.  
  159. MF_equ0        set all elements to 0
  160. MF_equ1        identity matrix: set all diagonal elements to 1.0,
  161.                all others to 0
  162. MF_outerprod   matrix formed by the "outer product" of two vectors
  163.  
  164. MF_Row_equC    set all elements of one specific row to the constant C
  165. MF_Col_equC    set all elements of one specific column to the constant C
  166. MF_Dia_equC    set all diagonal elements to the constant C
  167. MF_Row_equV    copy a vector into one specific row
  168. MF_Col_equV    copy a vector into one specific column
  169. MF_Dia_equV    copy a vector into the diagonal
  170.  
  171. MF_equM        make one matrix the copy of another
  172. MF_UequL       copy lower-diagonal elements into upper-diagonal
  173.                by index-reflection, so as to get a symmetric matrix
  174. MF_LequU       copy upper-diagonal elements into lower-diagonal
  175.  
  176. Two-dimensional windows for spectral analysis are provided by:
  177. MF_Hanning     Hanning window
  178. MF_Parzen      Parzen window
  179. MF_Welch       Welch window
  180.  
  181.  
  182. 4. Data-Type Conversions
  183. ------------------------
  184.  
  185. Matrices of every data type can be converted into every other.
  186. Only a few examples are given; the rest should be obvious.
  187.  
  188. M_FtoD    fMatrix to dMatrix
  189. M_CDtoCF  cdMatrix to cfMatrix (with overflow protection)
  190. M_DtoE    dMatrix to eMatrix
  191.  
  192.  
  193. 5. Transposing and Extracting Parts from a Matrix
  194. -------------------------------------------------
  195.  
  196. MF_transpose        transpose a matrix
  197.  
  198. MF_submatrix        extract a submatrix
  199. MF_submatrix_equM   copy a submatrix back into another (normally larger)
  200.                     matrix
  201.  
  202. MF_Row_extract      extract a single row and copy it into a vector
  203. MF_Col_extract      extract a single column and copy it into a vector
  204. MF_Dia_extract      extract the diagonal and copy it into a vector
  205.  
  206.  
  207. 6. Arithmetic Operations Performed on a Single Row, Column, or the Diagonal
  208. ---------------------------------------------------------------------------
  209.  
  210. MF_Row_addC         add a constant to all elements of a specific row
  211. MF_Col_addC         add a constant to all elements of a specific column
  212. MF_Dia_addC         add a constant to all diagonal elements
  213. MF_Row_addV         add corresponding vector elements to all elements of a
  214.                     specific row
  215. MF_Col_addV         add corresponding vector elements to all elements of a
  216.                     specific column
  217. MF_Dia_addV         add corresponding vector elements to the diagonal elements
  218.  
  219. A few examples should suffice for the other functions of this family:
  220. MF_Row_subC         subtract a constant from all elements of a specific row
  221. MF_Col_subrC        reverse substraction: difference between column elements
  222.                     and a constant
  223. MF_Dia_mulV         multiply the diagonal elements with corresponding vector
  224.                     elements
  225. MF_Row_divV         divide all elements of a specific row by corresponding
  226.                     vector elements
  227. MF_Col_divrC        reverse division: division of a constant by the individual
  228.                     column elements
  229.  
  230.  
  231. 7. Operations Performed Along All Rows or All Columns Simultaneously,
  232.          or Along the Diagonal of a Square Matrix
  233. ----------------------------------------------------------------------
  234.  
  235. MF_Rows_max         store the maxima of all rows in a column vector
  236. MF_Cols_max         store the maxima of all colums in a row vector
  237. MF_Dia_max          return the maximum of the diagonal as a scalar
  238.  
  239. MF_Rows_min         store the minima of all rows in a column vector
  240. MF_Cols_min         store the minima of all colums in a row vector
  241. MF_Dia_min          return the minimum of the diagonal as a scalar
  242.  
  243. MF_Rows_absmax      store the absolute maxima of all rows in a column vector
  244. MF_Cols_absmax      store the absolute maxima of all colums in a row vector
  245. MF_Dia_absmax       return the absolute maximum of the diagonal as a scalar
  246. MF_Rows_absmin      store the absolute minima of all rows in a column vector
  247. MF_Cols_absmin      store the absolute minima of all colums in a row vector
  248. MF_Dia_absmin       return the absolute minimum of the diagonal as a scalar
  249.  
  250. MF_Rows_sum         sum, taken along rows and stored in a column vector
  251. MF_Cols_sum         sum, taken along colums and stored in a row vector
  252. MF_Dia_sum          sum of the diagonal elements
  253.  
  254. MF_Rows_prod        product, taken along rows and stored in a column vector
  255. MF_Cols_prod        product, taken along colums and stored in a row vector
  256. MF_Dia_prod         product of the diagonal elements
  257.  
  258. MF_Rows_runsum      running sum along rows
  259. MF_Cols_runsum      running sum along columns
  260. MF_Rows_runprod     running product along rows
  261. MF_Cols_runprod     running product along columns
  262.  
  263. MF_Rows_rotate      rotate all rows by a specified number of positions
  264. MF_Cols_rotate      rotate all rows by a specified number of positions
  265. MF_Rows_reflect     set the upper halves of all rows equal to their reversed
  266.                     lower halves
  267. MF_Cols_reflect     set the upper halves of all columns equal to their
  268.                     reversed lower halves
  269.  
  270.  
  271. 8. Operations Involving Two Rows or Two Colums
  272. ----------------------------------------------
  273.  
  274. MF_Rows_exchange   exchange two rows
  275. MF_Cols_exchange   exchange two columns
  276.  
  277. MF_Rows_add        add two rows  (destination += source)
  278. MF_Cols_add        add two columns 
  279.  
  280. MF_Rows_sub        subtract two rows (destination -= source)
  281. MF_Cols_sub        subtract two columns
  282.  
  283. MF_Rows_Cadd       add scaled row to another (destination += C * source)
  284. MF_Cols_Cadd       add scaled column to another
  285.  
  286. MF_Rows_lincomb    linear combination of two rows
  287. MF_Cols_lincomb    linear combination of two columns
  288.  
  289.  
  290. 9. Matrix Multiplication
  291. ------------------------
  292.  
  293. MF_mulV            multiply a matrix by a column vector
  294. VF_mulM            multiply a row vector by a matrix
  295. MF_mulM            multiply two matrices
  296.  
  297. 10. Linear Algebra
  298. ------------------
  299.  
  300. There are three groups of linear algebra functions. The first group consists
  301. of "easy-to-use" versions which can be used as black-box functions without
  302. caring about their internal working. The second group consists of functions
  303. for LU decomposition and its applications. The third group, finally, is
  304. devoted to Singular Value Decomposition (SVD).
  305. Here are the "easy-to-use" versions of linear algebra functions:
  306.  
  307. MF_solve          solve simultaneous linear equations, using LU decomposition
  308. MF_inv            invert a matrix
  309. MF_det            determinant of a matrix
  310. MF_solveBySVD     solve simultaneous linear equations, using Singular Value
  311.                   Decomposition
  312. MF_safeSolve      try first solution by LUD; if that fails, SVD is done.
  313.  
  314. Now some functions for LU decomposition and for treatment of LU decomposed
  315. matrices:
  316.  
  317. MF_LUdecompose    decompose into LU form
  318. MF_LUimprove      improve accuracy of LU decomposition by iteration
  319. MF_LUDresult      check if MF_LUdecompose was successful (return value: 0)
  320.                   or not (return value 1 for singular matrices)
  321. MF_LUDsetEdit     set editing threshold for MF_LUdecompose; this is a crude
  322.                   way to work around near-singularities: if, in the partial
  323.                   pivoting process employed in the decomposition, no diagonal
  324.                   element larger than the threshold is available, the
  325.                   scaling of the matrix is done with the threshold value
  326.                   rather than with the tiny diagonal element.
  327. MF_LUDgetEdit     retrieve currently set threshold
  328. MF_LUsolve        solve simultaneous linear equations, given the matrix in
  329.                   LU form as obtained by MF_LUdecompose
  330. MF_LUinv          invert matrix already decomposed into LU form
  331. MF_LUdet          determinant of matrix already decomposed into LU form
  332.  
  333. Singular Value Decomposition and related functions are offered as:
  334.  
  335. MF_SVdecompose    Singular Value Decomposition
  336. MF_SVsolve        solve SV-decomposed set of linear equations
  337. MF_SVimprove      iterative improvement of solution found by MF_SVsolve
  338. MF_SVDsetEdit     set threshold for Singular Value editing
  339. MF_SVDgetEdit     retrieve current threshold for Singular Value editing
  340.  
  341.  
  342. 11. Eigenvalues and Eigenvectors
  343. --------------------------------
  344.  
  345. At present, only the special, but most frequent case of a symmetric real
  346. matrix is covered, whose eigenvalues, with or without eigenvectors, are
  347. calculated by MFsym_eigenvalues.
  348.  
  349.  
  350. 12. Two-Dimensional Fourier-Transform Methods
  351. ---------------------------------------------
  352.  
  353. By analogy with the corresponding one-dimensional Fourier Transform methods
  354. described in the VectorLib handbook, the following functions for the two-
  355. dimensional case are available in MatrixLib:
  356.  
  357. MF_FFT            Fast Fourier Transform
  358. MF_convolve       Convolution with a spacial response function
  359. MF_deconvolve     Deconvolution
  360. MF_filter         Spatial filtering
  361. MF_autocorr       Spatial autocorrelation
  362. MF_xcorr          Spatial cross-correlation
  363. MF_spectrum       Spatial frequency spectrum
  364.  
  365.  
  366. 13. Data Fitting
  367. ----------------
  368.  
  369. The functions for fitting X-Y pairs of data are included in MatrixLib rather
  370. than in VectorLib, because they rely heavily on matrix methods. Their prefix,
  371. VF_, however, is a reminder that they actually work on vectors, rather than
  372. on matrices. (The weighted variants actually do also require a matrix as
  373. argument, as they calculate the covariance matrix of parameters).
  374.  
  375. Only linear regression (i.e., data fitting to a straight line), does not
  376. employ matrix methods and is contained in VectorLib: VF_linregress.
  377.  
  378. MatrixLib provides a broad range of data fitting functions for various
  379. classes of model functions.  The most simple model functions are polynomials:
  380.     y = a0 + a1x + a2x*x ...
  381. Here, you are interested in the coefficients ai up to a certain limit,
  382. determined by the desired degree of the polynomial. All coefficients
  383. are treated as free parameters, without the possibility of "fixing" those
  384. whose values you happen to know beforehand.
  385. Polynomial fitting is most useful for degrees of 2 to 4. With degrees higher
  386. than 5, you will be able to fit almost any data - but the resulting
  387. coefficients will be at best inaccurate and at worst useless, as already
  388. very little experimental noise will strongly influence the balance of the
  389. higher terms. If you do need polynomials of higher degrees, you should
  390. carefully examine your problem to see which terms you can eliminate. This
  391. leads from polynomials to the next class of fitting functions, namely
  392. "general linear" functions.
  393.  
  394. In this general linear case, you have to write the model function yourself
  395. and pass it as an argument to the fitting routine.  The word "linear" means
  396. that the model function consists of a linear combination of basis functions
  397. each of which depends linearly on the fitting coefficients:
  398.  
  399.     y = a0f0(x) + a1f1(x) + a2f2(x)...
  400.  
  401. The individual functions fi(x)may be non-linear in x, but not in the
  402. coefficients ai.
  403. For example,  y = a0sin(x)+ a1cos(x) is a valid linear fitting function,
  404. but y = sin(a0x)+ cos(a1x) is not. Rather, this latter function leads us
  405. to the last and most general class of model functions, the non-linear models.
  406.  
  407. Fits to linear model functions (which include, of course, simple
  408. polynomials) are performed internally by solving a set of coupled linear
  409. equations - which is basically a simple matrix inversion process. The
  410. situation for non-linear model functions is completely different: no closed-
  411. form solution exists, and the fitting problem can be solved only iteratively.
  412. Therefore, fitting to non-linear models is much more time-consuming (by 3-5
  413. orders of magnitude!) than fitting to linear models. Two non-linear fitting
  414. algorithms are offered: the Levenberg-Marquardt method, and the Downhill-
  415. Simplex method by Nelder and Mead. As a starting-point, it is normally a
  416. good idea to choose a combination of both (choose
  417.       FitOptions.LevelOfMethod = 3,    see below).
  418.  
  419. The fundamental difference between linear and non-linear data fitting is
  420. reflected also in the required formulation of the model functions. In the
  421. linear case, the model function has to be provided in a form which
  422. calculates the individual basis functions for each x-value present in the
  423. data set. The above example with sine and cosine functions would be
  424. coded as
  425.     void LinModel( fVector BasFuncs, float x, unsigned nfuncs )
  426.     {
  427.         BasFuncs[0] = sin(x);
  428.         BasFuncs[1] = cos(x);
  429.     }
  430. Note that the coefficients ai are not used in the model function itself.
  431. The argument nfuncs (which is neglected in the above example) allows to
  432. use a variable number of basis functions.
  433. It is also possible to switch fitting parameters "on" and "off", i.e.,
  434. "free" or "fixed". To this end, the routine VF_linfit takes a "status"
  435. array as an argument. For all members of the parameter vector that are to
  436. be treated as free, the corresponding "status" entry must be set to 1.
  437. If status[i] is set to 0, the corresponding parameter, a[i], is treated
  438. as fixed at the value initialized before calling VF_linfit.
  439.  
  440. In the non-linear case, it is not the individual basis functions which are
  441. needed. Rather, the model function will be called by VF_nonlinfit with the
  442. whole X-vector as input argument and has to return the whole Y-vector.
  443. For the above non-linear sine and cosine example, this would be coded as
  444.  
  445.     void NonlinModel( fVector Y, fVector X, ui size)
  446.     {
  447.         for( ui i=0; i<size; i++ )
  448.             Y[i] = sin( a[0]*X[i] ) + cos( a[1]*X[i] );
  449.     }
  450.  
  451. The parameter array "a" should be global. It is passed as an argument to
  452. VF_nonlinfit, and its elements are changed during the fitting process. Upon
  453. input, "a" must (!) contain your initial "best guess" of the parameters.
  454. The better your guess, the faster VF_nonlinfit will converge. If your
  455. initial guess is too far off, convergence might be very slow or even never
  456. attained.
  457.  
  458. For actual working examples of code for the polynomial, general linear,
  459. and general non-linear cases, please see the file FITDEMO.CPP.
  460.  
  461. In addition to the fitting functions for single data sets, there are
  462. routines for fitting multiple data sets simultaneously. Say, you are a
  463. physicist or a chemist and want to measure a rate constant k. You have
  464. performed the same kinetic measurement ten times under slightly different
  465. conditions. All these measurements have, of course, the same k, but other
  466. parameters, like amplitude and time-zero, will differ from experiment
  467. to experiment. Now, the usual way would be to perform one fit for each of
  468. these ten data sets and average over the resulting k's. There is a problem
  469. with this approach: you don't really know which weight you have to assign
  470. to each of the measurements, and how to treat the overlapping error margins
  471. of the individual fits. You might want to perform a fit on all your data
  472. sets simultaneously, taking the same k for all data sets, and assigning
  473. individual amplitudes etc. to each set. This is precisely what the multifit
  474. functions of MatrixLib are designed for.
  475.  
  476. Here is an overview over the fitting routines provided by MatrixLib:
  477.  
  478. VF_polyfit        fit an X-Y data pair to a polynomial of arbitrary degree
  479. VF_polyfitwW      the same with non-equal weighting of individual data points
  480. VF_linfit         fit an X-Y data pair to a function linear in its parameters
  481. VF_linfitwW       the same with non-equal weighting of individual data points
  482. VF_nonlinfit      fit X-Y data to an arbitrary, possibly non-linear function
  483. VF_nonlinfitwW    the same for non-equal data-point weighting
  484. VF_multiLinfit       fit multiple X-Y data sets to one common model,
  485.                      linear in its parameters
  486. VF_multiLinfitwW     the same for non-equal data-point weighting
  487. VF_multiNonlinfit    fit multiple X-Y data sets to one common model,
  488.                      possibly nonlinear in its parameters
  489. VF_multiNonlinfitwW  the same for non-equal data-point weighting
  490.  
  491. With the exception of fitting to polynomials, which are present only for the
  492. X-Y data case, here are the corresponding functions for fitting
  493. z = f(x,y) data (with the prefix MF_):
  494.  
  495. MF_linfit         fit X-Y-Z data to a function linear in its parameters
  496. MF_linfitwW       the same with non-equal weighting of individual data points
  497.  
  498. MF_nonlinfit      fit X-Y-Z data to an arbitrary, possibly non-linear function
  499. MF_nonlinfitwW    the same for non-equal data-point weighting
  500.  
  501. MF_multiLinfit       fit multiple X-Y-Z data sets to one common model,
  502.                      linear in its parameters
  503. MF_multiLinfitwW     the same for non-equal data-point weighting
  504. MF_multiNonlinfit    fit multiple X-Y-Z data sets to one common model,
  505.                      possibly nonlinear in its parameters
  506. MF_multiNonlinfitwW  the same for non-equal data-point weighting
  507.  
  508. The nonlinear fitting routines are highly sophisticated and offer the user
  509. a lot of different options. These options may be set by the function
  510. V_setNonlinfitOptions. To retrieve current settings, use
  511. V_getNonlinfitOptions.
  512.  
  513. All options are packed into a structure named VF_NONLINFITOPTIONS.
  514. VF_NONLINFITOPTIONS has the following fields:
  515.  
  516. int      FigureOfMerit       0: least squares fitting
  517.                              1: robust fitting, optimizing for minimum
  518.                                 absolute deviation
  519.                              Default: 0
  520.  
  521. float    AbsTolChi           absolute change of chi (default: EPSILON)
  522. float    FracTolChi          fractional change of chi
  523.                                     (default: SQRT_EPSILON)
  524. float    AbsTolPar           absolute change of all parameters
  525.                                     (default: SQRT_MIN) 
  526. float    FracTolPar          fractional change of all parameters
  527.                                     (default: SQRT_EPSILON)
  528.                              These four parameters describe the convergence
  529.                              conditions: if the changes achieved in successive
  530.                              iterations are smaller than demanded by these
  531.                              criteria, this signals convergence. Set those
  532.                              criteria to 0.0, which are not applicable
  533.  
  534. unsigned HowOftenFulfill     how often fulfill one of the above conditions
  535.                              before convergence is considered achieved
  536.                              (default: 3)
  537.  
  538. unsigned LevelOfMethod       1: Levenberg-Marquardt method,
  539.                              2: Downhill Simplex (Nelder and Mead) method,
  540.                              3: both methods alternating;
  541.                                 add 4 to this in order to try
  542.                                 breaking out of local minima;
  543.                              0: no fit, calculate only chi2 (and Covar)
  544.                              (default: 1)
  545.  
  546. unsigned LevMarIterations    max.number of successful iterations of LevMar
  547.                              during one run (default: 100)
  548.  
  549. unsigned LevMarStarts        number of LevMar restarts per run (default: 2)
  550.  
  551. float    LambdaStart,
  552.          LambdaMin,
  553.          LambdaMax,
  554.          LambdaDiv,
  555.          LambdaMul           treatment of LevMar parameter lambda (don't
  556.                              touch, unless you are an expert!)
  557.  
  558. unsigned DownhillIterations  max. number of successful iterations in Downhill
  559.                              Simplex method  (default: 200)
  560.  
  561. float    DownhillReflection,
  562.          DownhillContraction,
  563.          DownhillExpansion   treatment of re-shaping of the simplex in
  564.                              Downhill Simplex method  (don't touch
  565.                              unless you are an expert!)
  566.  
  567. unsigned TotalStarts;        max. number of LevMar/Downhill pairs
  568.                              (default: 16)
  569.  
  570. fVector  UpperLimits;        impose upper limits on parameters. Default: NULL
  571. fVector  LowerLimits         impose lower limits on parameters. Default: NULL
  572.  
  573. void     (*Restrictions)(void);  user-defined function, implementing
  574.                              restrictions on the parameters which cannot be
  575.                              formulated as simple upper/lower limits.
  576.                              The function must check the whole parameter
  577.                              vector and edit the parameters as needed.
  578.                              Default: NULL
  579.  
  580.  
  581. The multifit functions, i.e. those which allow the treatment of several
  582. X-Y or X-Y-Z data sets simultaneously, need the data to be passed in
  583. structures named VF_EXPERIMENT for X-Y data and MF_EXPERIMENT for X-Y-Z
  584. data:
  585.  
  586. VF_EXPERIMENT has the following fields:
  587.  
  588. fVector X, Y               X and Y vectors
  589. fVector InvVar             inverse variances of the individual vector
  590.                            elements (needed only for the "with weights"
  591.                            functions)
  592. ui      size               the number of vector elements
  593. float   WeightOfExperiment individual weight to be assigned to the
  594.                            whole experiment (again needed only for
  595.                            the weighted variants)
  596.  
  597. MF_EXPERIMENT has the following fields:
  598.  
  599. fVector   X, Y             X and Y vectors (independent variables)
  600. fMatrix   MZ               measured data z=f(x,y)
  601. fMatrix   MInvVar          inverse variances of the individual matrix
  602.                            elements (needed only for the "with weights"
  603.                            functions)
  604. unsigned  htZ, lenZ        matrix dimensions
  605. float     WeightOfExperiment weight to be assigned to the whole
  606.                            experiment (again needed only for
  607.                            the weighted variants)
  608.  
  609.  
  610. 14. Matrix Input and Output
  611. ---------------------------
  612.  
  613. The matrix input/output functions are all analogous to the corresponding
  614. vector functions
  615.  
  616. MF_cprint   print a matrix to the screen. If necessary, rows are cut off
  617.             at the screen boundaries. If there are more rows than screen
  618.             lines, proper paging is applied.
  619. MF_print    print a matrix to the screen (without paging or row cut-off)
  620. MF_fprint   print a matrix in ASCII format to a stream.
  621.  
  622. MF_store    store in binary format
  623. MF_recall   retrieve in binary format
  624. MF_write    write in ASCII format in a stream
  625. MF_read     read from an ASCII file.
  626.  
  627.  
  628. 15. Graphical Representation of Matrices
  629. ----------------------------------------
  630.  
  631. True 3D-plotting functions will be included only in future versions.
  632. For now, only color-density plots are available. In these plots, each
  633. data value is translated into a color value by linear interpolatiion
  634. between two colors, specified as mincolor and maxcolor.
  635.  
  636. MF_xyzAutoDensityMap    Color density map for z=f(x,y) with automatic
  637.                         scaling of the X and Y axes and of the color
  638.                         density scale between mincolor and maxcolor.
  639. MF_xyzDataDensityMap    z=f(x,y) color density map, plotted into an
  640.                         existing axis frame, and using the color density
  641.                         scale set by the last call to an "AutoDensityMap"
  642.                         function.
  643. MF_zAutoDensityMap      Color density map for z=f(i,j) with automatic
  644.                         scaling of the X and Y axes and of the color
  645.                         density scale between mincolor and maxcolor.
  646.                         i and j are the indices in X and Y direction,
  647.                         respectively.
  648. MF_zDataDensityMap      Color density map for z=f(i,j), plotted into
  649.                         an existing axis frame, and using the color
  650.                         density scale set by the last call to an
  651.                         "AutoDensityMap" function.
  652.  
  653.  
  654. 16. Alphabetical Syntax Reference
  655. ---------------------------------
  656.  
  657. This chapter summarizes, in alphabetical order, the syntax of MatrixLib
  658. functions. As usual, the MF_ or M_ prefix is neglected in the ordering
  659. of entries. The particles "Row_", "Rows_", "Col_", "Cols_", and "Dia_",
  660. however, are fully taken into account. For example, "MF_Rows_" functions
  661. will come after all "MF_Row_" functions. While most MatrixLib functions
  662. have the prefixes MF_ or M_, please note that some - notably the X-Y
  663. fitting functions - have the prefix VF_. These functions have been included
  664. into MatrixLib, because they use matrix methods. Their prefix is a reminder,
  665. however, that their functional behaviour is aimed at vectors more than on
  666. matrices, as, e.g., in VF_linfit.
  667.  
  668. void    MF_addM( fMatrix MC, fMatrix MA, fMatrix MB,
  669.                  unsigned ht, unsigned len );
  670. void    MFs_addM( fMatrix MC, fMatrix MA, fMatrix MB,
  671.                   unsigned ht, unsigned len, float C );
  672. void    MF_autocorr( fMatrix MACorr, fMatrix MX,
  673.                      unsigned ht, unsigned len );
  674. void    M_CDtoCE( ceMatrix MF, cdMatrix MD, unsigned ht, unsigned len );
  675. void    M_CDtoCF( cfMatrix MF, cdMatrix MD, unsigned ht, unsigned len );
  676. void    M_CEtoCD( cdMatrix MF, ceMatrix MD, unsigned ht, unsigned len );
  677. void    M_CEtoCF( cfMatrix MF, ceMatrix MD, unsigned ht, unsigned len );
  678. void    M_CFtoCD( cdMatrix MF, cfMatrix MD, unsigned ht, unsigned len );
  679. void    M_CFtoCE( ceMatrix MF, cfMatrix MD, unsigned ht, unsigned len );
  680. void    MF_Col_addC( fMatrix MA, unsigned ht, unsigned len,
  681.                          unsigned iCol, float C );
  682. void    MF_Col_addV( fMatrix MA, unsigned ht, unsigned len,
  683.                          unsigned iCol, fVector X );
  684. void    MF_Col_divC( fMatrix MA, unsigned ht, unsigned len,
  685.                          unsigned iCol, float C );
  686. void    MF_Col_divrC( fMatrix MA, unsigned ht, unsigned len,
  687.                          unsigned iCol, float C );
  688. void    MF_Col_divrV( fMatrix MA, unsigned ht, unsigned len,
  689.                          unsigned iCol, fVector X );
  690. void    MF_Col_divV( fMatrix MA, unsigned ht, unsigned len,
  691.                          unsigned iCol, fVector X );
  692. void    MF_Col_equC( fMatrix MA, unsigned ht, unsigned len,
  693.                      unsigned iCol, float C );
  694. void    MF_Col_equV( fMatrix MA, unsigned ht, unsigned len,
  695.                      unsigned iCol, fVector X );
  696. void    MF_Col_extract( fVector Y, fMatrix MA, unsigned ht, unsigned len,
  697.                         unsigned iCol );
  698. void    MF_Col_mulC( fMatrix MA, unsigned ht, unsigned len,
  699.                          unsigned iCol, float C );
  700. void    MF_Col_mulV( fMatrix MA, unsigned ht, unsigned len,
  701.                          unsigned iCol, fVector X );
  702. void    MF_Col_subC( fMatrix MA, unsigned ht, unsigned len,
  703.                          unsigned iCol, float C );
  704. void    MF_Col_subrC( fMatrix MA, unsigned ht, unsigned len,
  705.                          unsigned iCol, float C );
  706. void    MF_Col_subV( fMatrix MA, unsigned ht, unsigned len,
  707.                          unsigned iCol, fVector X );
  708. void    MF_Col_subrV( fMatrix MA, unsigned ht, unsigned len,
  709.                          unsigned iCol, fVector X );
  710. void    MF_Cols_absmax( fVector Y, fMatrix MA, unsigned ht, unsigned len );
  711. void    MF_Cols_absmin( fVector Y, fMatrix MA, unsigned ht, unsigned len );
  712. void    MF_Cols_add( fMatrix MA, unsigned ht, unsigned len,
  713.                      unsigned destCol, unsigned sourceCol );
  714. void    MF_Cols_Cadd( fMatrix MA, unsigned ht, unsigned len,
  715.                       unsigned destCol, unsigned sourceCol, float C );
  716. void    MF_Cols_exchange( fMatrix MA, unsigned ht, unsigned len,
  717.                           unsigned i1, unsigned i2 );
  718. void    MF_Cols_lincomb( fMatrix MA, unsigned ht, unsigned len,
  719.                          unsigned destCol,  float  destC,
  720.                          unsigned srceCol,  float  srceC );
  721. void    MF_Cols_max( fVector Y, fMatrix MA, unsigned ht, unsigned len );
  722. void    MF_Cols_min( fVector Y, fMatrix MA, unsigned ht, unsigned len );
  723. void    MF_Cols_prod(fVector Y, fMatrix MA, unsigned ht, unsigned len );
  724. void    MF_Cols_reflect( fMatrix MA, unsigned ht, unsigned len );
  725. void    MF_Cols_rotate( fMatrix MA, unsigned ht, unsigned len, int pos );
  726. void    MF_Cols_runprod( fMatrix MA, unsigned ht, unsigned len );
  727. void    MF_Cols_runsum( fMatrix MA, unsigned ht, unsigned len );
  728. void    MF_Cols_sub( fMatrix MA, unsigned ht, unsigned len,
  729.                      unsigned destCol, unsigned sourceCol );
  730. void    MF_Cols_sum( fVector Y, fMatrix MA, unsigned ht, unsigned len );
  731. void    MF_convolve( fMatrix MY, fMatrix MFlt, fMatrix MX,
  732.                      fMatrix MRsp, unsigned ht, unsigned len );
  733. void    MF_cprint( fMatrix MA, unsigned ht, unsigned len );
  734. void    MF_deconvolve( fMatrix MY, fMatrix MFlt, fMatrix MX,
  735.                        fMatrix MRsp, unsigned ht, unsigned len );
  736. float   MF_det( fMatrix MA, unsigned len );
  737. float   MF_Dia_absmax(  fMatrix MA, unsigned len );
  738. float   MF_Dia_absmin(  fMatrix MA, unsigned len );
  739. void    MF_Dia_addC( fMatrix MA, unsigned len, float C );
  740. void    MF_Dia_addV( fMatrix MA, unsigned len, fVector X );
  741. void    MF_Dia_divC( fMatrix MA, unsigned len, float C );
  742. void    MF_Dia_divrC( fMatrix MA, unsigned len, float C );
  743. void    MF_Dia_divrV( fMatrix MA, unsigned len, fVector X );
  744. void    MF_Dia_divV( fMatrix MA, unsigned len, fVector X );
  745. void    MF_Dia_equC( fMatrix MA, unsigned len, float C );
  746. void    MF_Dia_equV( fMatrix MA, unsigned len, fVector X );
  747. void    MF_Dia_extract( fVector Y, fMatrix MA, unsigned len );
  748. float   MF_Dia_max(  fMatrix MA, unsigned len );
  749. float   MF_Dia_min(  fMatrix MA, unsigned len );
  750. void    MF_Dia_mulC( fMatrix MA, unsigned len, float C );
  751. void    MF_Dia_mulV( fMatrix MA, unsigned len, fVector X );
  752. float   MF_Dia_prod( fMatrix MA, unsigned len );
  753. void    MF_Dia_subrC( fMatrix MA, unsigned len, float C );
  754. void    MF_Dia_subrV( fMatrix MA, unsigned len, fVector X );
  755. void    MF_Dia_subC( fMatrix MA, unsigned len, float C );
  756. void    MF_Dia_subV( fMatrix MA, unsigned len, fVector X );
  757. float   MF_Dia_sum(  fMatrix MA, unsigned len );
  758. void    MF_divC( fMatrix MB, fMatrix MA, unsigned ht, unsigned len, float C );
  759. void    M_DtoE( eMatrix MF, dMatrix MD, unsigned ht, unsigned len );
  760. void    M_DtoF( fMatrix MF, dMatrix MD, unsigned ht, unsigned len );
  761.  
  762. float   MF_element( fMatrix X, unsigned ht, unsigned len,
  763.                     unsigned m, unsigned n );
  764. void    MFsym_eigenvalues( fVector EigV, fMatrix EigM, fMatrix MA,
  765.                            unsigned len, int CalcEigenVec );
  766. void    MF_equ0( fMatrix MA, unsigned ht, unsigned len );
  767. void    MF_equ1( fMatrix MA, unsigned len );  /* identity matrix */
  768. void    MF_equM( fMatrix MB, fMatrix MA, unsigned ht, unsigned len );
  769. void    M_EtoD( dMatrix MF, eMatrix MD, unsigned ht, unsigned len );
  770. void    M_EtoF( fMatrix MF, eMatrix MD, unsigned ht, unsigned len );
  771. void    MF_filter( fMatrix MY, fMatrix MX, fMatrix MFlt,
  772.                    unsigned ht, unsigned len );
  773. void    MF_FFT( fMatrix MY, fMatrix MX,
  774.                  unsigned ht, unsigned len, int dir );
  775. void    M_findDensityMapBounds( extended xmin, extended xmax,
  776.                                 extended ymin, extended ymax,
  777.                                 extended zmin, extended zmax,
  778.                                 COLORREF mincolor, COLORREF maxcolor );
  779. void    MF_fprint( FILE  *stream, fMatrix MA, unsigned ht,
  780.                      unsigned len, unsigned linewidth );
  781. void    M_free( void **M );
  782. void    M_FtoD( dMatrix MF, fMatrix MD, unsigned ht, unsigned len );
  783. void    M_FtoE( eMatrix MF, fMatrix MD, unsigned ht, unsigned len );
  784. float   VF_getLinfitNeglect( void );
  785. void    VF_getNonlinfitOptions( VF_NONLINFITOPTIONS *Options );
  786. void    MF_Hanning( fMatrix MA, unsigned ht, unsigned len );
  787. int     MF_inv( fMatrix MInv, fMatrix MA, unsigned len );
  788. void    MF_LequU( fMatrix MA, unsigned len );
  789. void    MF_lincomb( fMatrix MC, fMatrix MA, fMatrix MB,
  790.                     unsigned ht, unsigned len, float CA, float CB );
  791. void    VF_linfit( fVector A, iVector AStatus, unsigned npars,
  792.                    fVector X, fVector Y, ui sizex,
  793.                    void (*funcs)(fVector BasFuncs, float x, unsigned nfuncs));
  794. void    VF_linfitwW( fVector A, fMatrix Covar, iVector AStatus,
  795.                  unsigned npars,
  796.                  fVector X, fVector Y, fVector InvVar, ui sizex,
  797.                  void (*funcs)(fVector BasFuncs, float x, unsigned nfuncs));
  798. void    MF_linfit( fVector A, iVector AStatus, unsigned npars,
  799.                fVector X, fVector Y, fMatrix MZ, unsigned htZ, unsigned lenZ,
  800.                void (*funcs)(fVector BasFuncs, float x, float y,
  801.                              unsigned nfuncs));
  802. void    MF_linfitwW( fVector A, fMatrix Covar, iVector AStatus,
  803.                      unsigned npars,
  804.                      fVector X, fVector Y, fMatrix MZ, fMatrix MInvVar,
  805.                      unsigned htZ, unsigned lenZ,
  806.                      void (*funcs)(fVector BasFuncs, float x, float y,
  807.                                    unsigned nfuncs));
  808. int     MF_LUdecompose( fMatrix MLU,  uiVector Ind, fMatrix MA,
  809.                             unsigned len );
  810. float   MF_LUdet( fMatrix MLU, unsigned len, int permut );
  811. float   MF_LUDgetEdit( void );
  812. void    MF_LUDsetEdit( float Thresh );
  813.      /*  Editing threshold for MF_LUdecompose; used to cure singularities */
  814. int     MF_LUDresult( void ); /* returns 0, if MF_LUdecompose was successful;
  815.                   returns 1, if MA was (nearly) singular in MF_LUdecompose. */
  816. void    MF_LUinv( fMatrix MInv, fMatrix MLU, uiVector Ind,
  817.                       unsigned len );
  818. void    MF_LUsolve( fVector X, fMatrix MLU, fVector B, uiVector Ind,
  819.                         unsigned len );
  820. void    MF_LUimprove( fVector X, fVector B, fMatrix MA, fMatrix MLU,
  821.                           uiVector Ind, unsigned len );
  822. fMatrix MF_matrix( unsigned ht, unsigned len );
  823. fMatrix MF_matrix0( unsigned ht, unsigned len );
  824. void    MF_mulC( fMatrix MB, fMatrix MA, unsigned ht, unsigned len, float C );
  825. void    MF_mulM( fMatrix MC, fMatrix MA, fMatrix MB,
  826.                     unsigned htA, unsigned lenA, unsigned lenB );
  827. void    VF_mulM( fVector Y, fVector X, fMatrix MA,
  828.                     unsigned sizX, unsigned lenA );
  829. void    MF_mulV( fVector Y, fMatrix MA, fVector X,
  830.                     unsigned htA, unsigned lenA );
  831. void    MF_multiLinfit( fVector A, iVector AStatus, unsigned npars,
  832.                 MF_EXPERIMENT *ListOfExperiments, unsigned nexperiments,
  833.                 void (*funcs)(fVector BasFuncs, float x, float y,
  834.                               unsigned nfuncs, unsigned iexperiment) );
  835. void    VF_multiLinfit( fVector A, iVector AStatus, unsigned npars,
  836.                 VF_EXPERIMENT *ListOfExperiments, unsigned nexperiments,
  837.                 void (*funcs)(fVector BasFuncs, float x,
  838.                               unsigned nfuncs, unsigned iexperiment) );
  839. void    MF_multiLinfitwW( fVector A, fMatrix Covar,
  840.                 iVector AStatus, unsigned npars,
  841.                 MF_EXPERIMENT *ListOfExperiments, unsigned nexperiments,
  842.                 void (*funcs)(fVector BasFuncs, float x, float y,
  843.                               unsigned nfuncs, unsigned nexperiment) );
  844. void    VF_multiLinfitwW( fVector A, fMatrix Covar,
  845.                 iVector AStatus, unsigned npars,
  846.                 VF_EXPERIMENT *ListOfExperiments, unsigned nexperiments,
  847.                 void (*funcs)(fVector BasFuncs, float x,
  848.                               unsigned nfuncs, unsigned nexperiment) );
  849. float   MF_multiNonlinfit( fVector A, iVector AStatus, unsigned npars,
  850.                MF_EXPERIMENT _VFAR *ListOfExperiments, unsigned nexperiments,
  851.                void (*modelfunc)(fMatrix MZModel, unsigned htZ, unsigned lenZ,
  852.                                  fVector X, fVector Y, unsigned iexperiment),
  853.                void (*derivatives)(fMatrix dZdAi, unsigned htZ, unsigned lenZ,
  854.                                    fVector X, fVector Y, unsigned ipar,
  855.                                    unsigned iexperiment) );
  856. float   VF_multiNonlinfit( fVector A, iVector AStatus, unsigned npars,
  857.                VF_EXPERIMENT _VFAR *ListOfExperiments, unsigned nexperiments,
  858.                void (*modelfunc)(fVector YModel, fVector XModel,
  859.                                  ui size, unsigned iexperiment),
  860.                void (*derivatives)(fVector dYdAi,fVector X, ui size,
  861.                                  unsigned ipar, unsigned iexperiment) );
  862.  
  863. void    VF_multiNonlinfit_autoDeriv( fVector dYdAi, fVector X, ui size,
  864.                                        unsigned iexperiment, unsigned ipar );
  865. void    MF_multiNonlinfit_autoDeriv(fMatrix dZdAi, unsigned htZ, unsigned lenZ,
  866.                                     fVector X, fVector Y,
  867.                                     unsigned ipar, unsigned iexperiment );
  868. void     MF_multiNonlinfit_getBestA( fVector ABest );
  869. void     VF_multiNonlinfit_getBestA( fVector ABest );
  870. float    MF_multiNonlinfit_getChi2( void );
  871. float    VF_multiNonlinfit_getChi2( void );
  872. int      MF_multiNonlinfit_getTestDir( void );
  873. int      VF_multiNonlinfit_getTestDir( void );
  874. unsigned MF_multiNonlinfit_getTestPar( void );
  875. unsigned VF_multiNonlinfit_getTestPar( void );
  876. unsigned MF_multiNonlinfit_getTestRun( void );
  877. unsigned VF_multiNonlinfit_getTestRun( void );
  878. void     MF_multiNonlinfit_stop( void );
  879. void     VF_multiNonlinfit_stop( void );
  880.  
  881. float   MF_multiNonlinfitwW( fVector A, fMatrix Covar,
  882.                 iVector AStatus, unsigned npars,
  883.                 MF_EXPERIMENT  *ListOfExperiments, unsigned nexperiments,
  884.                 void (*modelfunc)(fMatrix MZModel, unsigned htZ, unsigned lenZ,
  885.                                   fVector X, fVector Y, unsigned iexperiment ),
  886.                 void (*derivatives)(fMatrix dZdAi, unsigned htZ, unsigned lenZ,
  887.                                     fVector X, fVector Y,
  888.                                     unsigned ipar, unsigned iexperiment) );
  889. float   VF_multiNonlinfitwW( fVector A, fMatrix Covar,
  890.                 iVector AStatus, unsigned npars,
  891.                 VF_EXPERIMENT *ListOfExperiments, unsigned nexperiments,
  892.                 void (*modelfunc)(fVector YModel, fVector X, ui size,
  893.                                   unsigned iexperiment),
  894.                 void (*derivatives)(fVector dYdAi, fVector X, ui size,
  895.                                   unsigned ipar, unsigned iexperiment) );
  896. void    MF_multiNonlinfitwW_autoDeriv( fMatrix dZdAi,
  897.                                     unsigned htZ, unsigned lenZ,
  898.                                     fVector X, fVector Y,
  899.                                     unsigned ipar, unsigned iexperiment );
  900. void    VF_multiNonlinfitwW_autoDeriv( fVector dYdAi, fVector X, ui size,
  901.                                        unsigned iexperiment, unsigned ipar );
  902. void     MF_multiNonlinfitwW_getBestA( fVector ABest );
  903. void     VF_multiNonlinfitwW_getBestA( fVector ABest );
  904. float    MF_multiNonlinfitwW_getChi2( void );
  905. float    VF_multiNonlinfitwW_getChi2( void );
  906. int      MF_multiNonlinfitwW_getTestDir( void );
  907. int      VF_multiNonlinfitwW_getTestDir( void );
  908. unsigned MF_multiNonlinfitwW_getTestPar( void );
  909. unsigned VF_multiNonlinfitwW_getTestPar( void );
  910. unsigned MF_multiNonlinfitwW_getTestRun( void );
  911. unsigned VF_multiNonlinfitwW_getTestRun( void );
  912. void     MF_multiNonlinfitwW_stop( void );
  913. void     VF_multiNonlinfitwW_stop( void );
  914.  
  915.  
  916. void    M_nfree( unsigned n, ... );
  917. float   MF_nonlinfit( fVector A, iVector AStatus, unsigned npars,
  918.                     fVector X, fVector Y, fMatrix MZ, unsigned htZ, unsigned lenZ,
  919.                     void (*modelfunc)(fMatrix MZModel, unsigned htZ, unsigned lenZ, fVector X, fVector Y ),
  920.                     void (*derivatives)(fMatrix dZdAi, unsigned htZ, unsigned lenZ, fVector X, fVector Y, unsigned ipar) );
  921.        /* returns figure-of-merit of best A. If you don't know the partial
  922.           derivatives with respect to A, call with derivatives=NULL */
  923. float   MF_nonlinfitwW( fVector A, fMatrix Covar, iVector AStatus, unsigned npars,
  924.                     fVector X, fVector Y, fMatrix MZ, fMatrix MInvVar, unsigned htZ, unsigned lenZ,
  925.                     void (*modelfunc)(fMatrix MZModel, unsigned htZ, unsigned lenZ, fVector X, fVector Y ),
  926.                     void (*derivatives)(fMatrix dZdAi, unsigned htZ, unsigned lenZ, fVector X, fVector Y, unsigned ipar) );
  927. float   VF_nonlinfit( fVector A, iVector AStatus, unsigned npars,
  928.                       fVector X, fVector Y, ui sizex,
  929.                       void (*modelfunc)(fVector YModel, fVector XModel, ui size),
  930.                       void (*derivatives)(fVector dYdAi,fVector X, ui size, unsigned iPar) );
  931. float   VF_nonlinfitwW( fVector A, fMatrix Covar, iVector AStatus, unsigned npars,
  932.                     fVector X, fVector Y, fVector InvVar, ui sizex,
  933.                     void (*modelfunc)(fVector YModel, fVector X, ui size),
  934.                     void (*derivatives)(fVector dYdAi, fVector X, ui size, unsigned i) );
  935. void    MF_outerprod( fMatrix MA, fVector X,  fVector Y,
  936.                       unsigned ht, unsigned len );
  937. void    MF_Parzen( fMatrix MA, unsigned ht, unsigned len );
  938. float * MF_Pelement( fMatrix X, unsigned ht, unsigned len,
  939.                      unsigned m, unsigned n );
  940. void    VF_polyfit( fVector A, unsigned deg, fVector X, fVector Y, ui sizex );
  941. void    VF_polyfitwW( fVector A, fMatrix Covar, unsigned deg,
  942.                       fVector X, fVector Y, fVector InvVar, ui sizex );
  943. void    MF_read( fMatrix X, unsigned ht, unsigned len, FILE  *stream );
  944. void    MF_recall( fMatrix MA, unsigned ht, unsigned len, FILE *stream);
  945. void    MF_Row_addC( fMatrix MA, unsigned ht, unsigned len,
  946.                          unsigned iRow, float C );
  947. void    MF_Row_addV( fMatrix MA, unsigned ht, unsigned len,
  948.                          unsigned iRow, fVector X );
  949. void    MF_Row_divC( fMatrix MA, unsigned ht, unsigned len,
  950.                          unsigned iRow, float C );
  951. void    MF_Row_divrC( fMatrix MA, unsigned ht, unsigned len,
  952.                          unsigned iRow, float C );
  953. void    MF_Row_divrV( fMatrix MA, unsigned ht, unsigned len,
  954.                          unsigned iRow, fVector X );
  955. void    MF_Row_divV( fMatrix MA, unsigned ht, unsigned len,
  956.                          unsigned iRow, fVector X );
  957. void    MF_Row_equC( fMatrix MA, unsigned ht, unsigned len,
  958.                      unsigned iRow, float C );
  959. void    MF_Row_equV( fMatrix MA, unsigned ht, unsigned len,
  960.                      unsigned iRow, fVector X );
  961. void    MF_Row_extract( fVector Y, fMatrix MA, unsigned ht, unsigned len,
  962.                         unsigned iRow );
  963. void    MF_Row_mulC( fMatrix MA, unsigned ht, unsigned len,
  964.                          unsigned iRow, float C );
  965. void    MF_Row_mulV( fMatrix MA, unsigned ht, unsigned len,
  966.                          unsigned iRow, fVector X );
  967. void    MF_Row_subC( fMatrix MA, unsigned ht, unsigned len,
  968.                          unsigned iRow, float C );
  969. void    MF_Row_subrC( fMatrix MA, unsigned ht, unsigned len,
  970.                          unsigned iRow, float C );
  971. void    MF_Row_subrV( fMatrix MA, unsigned ht, unsigned len,
  972.                          unsigned iRow, fVector X );
  973. void    MF_Row_subV( fMatrix MA, unsigned ht, unsigned len,
  974.                          unsigned iRow, fVector X );
  975. void    MF_Rows_absmax( fVector Y, fMatrix MA, unsigned ht, unsigned len );
  976. void    MF_Rows_absmin( fVector Y, fMatrix MA, unsigned ht, unsigned len );
  977. void    MF_Rows_add( fMatrix MA, unsigned ht, unsigned len,
  978.                      unsigned destRow, unsigned sourceRow );
  979. void    MF_Rows_Cadd( fMatrix MA, unsigned ht, unsigned len,
  980.                       unsigned destRow, unsigned sourceRow, float C );
  981. void    MF_Rows_exchange( fMatrix MA, unsigned ht, unsigned len,
  982.                          unsigned i1, unsigned i2 );
  983. void    MF_Rows_lincomb( fMatrix MA, unsigned ht, unsigned len,
  984.                          unsigned destRow,  float  destC,
  985.                          unsigned srceRow,  float  srceC );
  986. void    MF_Rows_max( fVector Y, fMatrix MA, unsigned ht, unsigned len );
  987. void    MF_Rows_min( fVector Y, fMatrix MA, unsigned ht, unsigned len );
  988. void    MF_Rows_prod(fVector Y, fMatrix MA, unsigned ht, unsigned len );
  989. void    MF_Rows_reflect( fMatrix MA, unsigned ht, unsigned len );
  990. void    MF_Rows_rotate( fMatrix MA, unsigned ht, unsigned len, int pos );
  991. void    MF_Rows_runprod( fMatrix MA, unsigned ht, unsigned len );
  992. void    MF_Rows_runsum( fMatrix MA, unsigned ht, unsigned len );
  993. void    MF_Rows_sub( fMatrix MA, unsigned ht, unsigned len,
  994.                      unsigned destRow, unsigned sourceRow );
  995. void    MF_Rows_sum( fVector Y, fMatrix MA, unsigned ht, unsigned len );
  996. int     MF_safeSolve( fVector X, fMatrix MA, fVector B, unsigned len );
  997.               /* ret.value 0: success via LUD; 1: success via SVD; -1: error */
  998.  
  999. void    M_setDensityMapBounds(  extended xmin, extended xmax,
  1000.                                 extended ymin, extended ymax,
  1001.                                 extended zmin, extended zmax,
  1002.                                 COLORREF mincolor, COLORREF maxcolor );
  1003. void    M_setDensityBounds(  extended zmin, extended zmax,
  1004.                              COLORREF mincolor, COLORREF maxcolor );
  1005.  
  1006. void    VF_setLinfitNeglect( float Thresh );
  1007.                 /* neglect A[i]=0, if significance smaller than Thresh */
  1008. void    VF_setNonlinfitOptions( VF_NONLINFITOPTIONS *Options );
  1009. void    MF_setWriteFormat( char *FormatString );
  1010. void    MF_setWriteSeparate( char *SepString );
  1011. int     MF_solve( fVector X, fMatrix MA, fVector B, unsigned len );
  1012. int     MF_solveBySVD( fVector X, fMatrix MA, fVector B,
  1013.                            unsigned htA, unsigned lenA );
  1014.               /*  sizX = lenA,  sizB = htA.  ret.value != 0 signals failure */
  1015. void    MF_spectrum( fMatrix MSpec, unsigned htSpec, unsigned lenSpec,
  1016.                      fMatrix MX, unsigned htX, unsigned lenX,
  1017.                      fMatrix MWin );
  1018.           /*   htSpec, lenSpec must be 2**n,
  1019.                MSpec has [htSpec+1][lenSpec+1] elements (!)
  1020.                htX >= n*htSpec,  lenX >= n*lenSpec,
  1021.                htWin = 2*htSpec, lenWin = 2*lenSpec     */
  1022.  
  1023. void    MF_store( FILE *str, fMatrix MA, unsigned ht, unsigned len );
  1024. void    MF_subM( fMatrix MC, fMatrix MA, fMatrix MB,
  1025.                  unsigned ht, unsigned len );
  1026. void    MFs_subM( fMatrix MC, fMatrix MA, fMatrix MB,
  1027.                   unsigned ht, unsigned len, float C );
  1028. void    MF_submatrix( fMatrix MSub,
  1029.                       unsigned subHt,  unsigned subLen,
  1030.                       fMatrix MSrce,
  1031.                       unsigned srceHt,  unsigned srceLen,
  1032.                       unsigned firstRowInCol,  unsigned sampInCol,
  1033.                       unsigned firstColInRow,  unsigned sampInRow );
  1034.  
  1035. void    MF_submatrix_equM( fMatrix MDest,
  1036.                            unsigned destHt,  unsigned destLen,
  1037.                            unsigned firstRowInCol,  unsigned sampInCol,
  1038.                            unsigned firstColInRow,  unsigned sampInRow,
  1039.                            fMatrix MSrce,
  1040.                            unsigned srceHt,  unsigned srceLen );
  1041. int     MF_SVdecompose( fMatrix MU, fMatrix MV, fVector W, fMatrix MA,
  1042.                            unsigned htA, unsigned lenA );
  1043. void    MF_SVDsetEdit( float Thresh );
  1044. float   MF_SVDgetEdit( void ); /* Override of the standard values for editing
  1045.                 threshholds in MF_SVsolve. Calling MF_setEdit with Thresh=0.0
  1046.                 means that you do the necessary editing of W yourself before
  1047.                 calling  MD_SVsolve                           */
  1048. void    MF_SVimprove(  fVector X, fVector B, fMatrix MA,
  1049.                        fMatrix MU, fMatrix MV, fVector W,
  1050.                        unsigned htA, unsigned lenA );
  1051. void    MF_SVsolve( fVector X, fMatrix MU, fMatrix MV, fVector W,
  1052.                        fVector B, unsigned htU, unsigned lenU );
  1053. void    MF_transpose( fMatrix MTr, fMatrix MA,
  1054.                        unsigned htTr, unsigned lenTr );
  1055. void    MF_UequL( fMatrix MA, unsigned len );
  1056. void    MF_Welch( fMatrix MA, unsigned ht, unsigned len );
  1057. void    MF_write( FILE  *stream, fMatrix X, unsigned ht, unsigned len  );
  1058. void    MF_xcorr( fMatrix MXCorr, fMatrix MX, fMatrix MY,
  1059.                      unsigned ht, unsigned len );
  1060. void    MF_xyzAutoDensityMap( fVector X, fVector Y, fMatrix MZ,
  1061.                               unsigned ht, unsigned len,
  1062.                               COLORREF mincolor, COLORREF maxcolor );
  1063. void    MF_xyzDataDensityMap( fVector X, fVector Y, fMatrix MZ,
  1064.                               unsigned ht, unsigned len );
  1065. void    MFzAutoDensityMap( fMatrix MZ, unsigned ht, unsigned len,
  1066.                              COLORREF mincolor, COLORREF maxcolor );
  1067. void    MFzDataDensityMap( fMatrix MZ, unsigned ht, unsigned len );
  1068.  
  1069.  
  1070. ****************************************************************************
  1071. *                                                                          *
  1072. *******                      E  N  D                                 *******
  1073. *                                                                          *
  1074. ****************************************************************************
  1075.  
  1076. Copyright for OptiVec software and documentation
  1077. (C) 1996-1999 Martin Sander.
  1078. All rights reserved!
  1079.